package Ep01_Array.Feb24th_2357;

import java.util.Arrays;

/**
 * @author Jimmy Zhan WORKSTATION
 * @Date 2023/2/24 13:55
 * 说明：力扣每日 2357 —— 贪心
 * 下策：暴力求解，排序 + 模拟
 */

public class Mine {

    public static void main(String[] args) {
        int[] nums = {0};
        Mine m = new Mine();
        System.out.println(m.minimumOperations(nums));
    }
    public int minimumOperations(int[] nums){
        Arrays.sort(nums);

        int counter = 0;
        int i, j;
        for (i = 0; i < nums.length; i++) {
            if (nums[i] != 0){
                counter++;
                for (j = nums.length-1; j >= i; j--) {
                    if (nums[j] != 0) {
                        nums[j] -= nums[i];
                    }
                }
            }
        }
        return counter;
    }
}
